package com.mooc.yohoshop.network;

import com.google.gson.Gson;
import com.mooc.yohoshop.entity.BaseEntity;
import com.mooc.yohoshop.network.function.ConvertFunction;

import java.util.ArrayList;
import java.util.HashMap;

import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;

public class BaseRepository {

    //创建body
    protected RequestBody createBody(HashMap map){
        return RequestBody.create(MediaType.parse("application/json"),new Gson().toJson(map));
    }
    protected RequestBody createBody(ArrayList list){
        return RequestBody.create(MediaType.parse("application/json"),new Gson().toJson(list));
    }
    //转化
    protected Observable<BaseEntity>convertObservable(Observable observable){
        return observable.map(new ConvertFunction());
    }


}
